package com.realife.eson.common.exception;

import com.realife.eson.common.enums.ResponseEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = false)
public class BusinessException extends RuntimeException {

    //错误码
    private Integer statusCode;


    public BusinessException() {
    }


    public BusinessException(String Message) {
        super(Message);
        this.statusCode = 999;
    }


    /**
     *
     * @param responseEnum
     */
    public BusinessException(ResponseEnum responseEnum) {
        super(responseEnum.getMessage());
        this.statusCode = responseEnum.getStatusCode();
    }


    /**
     *
     * @param responseEnum
     * @param cause
     */
    public BusinessException(ResponseEnum responseEnum, Throwable cause) {
        super(responseEnum.getMessage(), cause);
        this.statusCode = responseEnum.getStatusCode();
    }
}
